<?php


	namespace Midi\Event;
	
	use \Midi\Event;
	use \Midi\Util\Util;

	abstract class ChannelEvent implements Event, Parameterized {
		
		protected $channel;
		
		protected $param1;
		
		protected $param2;
		
		private $isContinuation;
		
		public function __construct($channel, $param1, $param2 = null, $isContinuation = false) {
			$this->channel        = $channel;
			$this->param1         = $param1;
			$this->param2         = $param2;
			$this->isContinuation = $isContinuation;
		}
		
		public function __toString() {
			return $this->getParamDescription();
			
		}
		public function getChannelNo() {
			return $this->channel;
		}
		public function toBinary() {
			$binary = ($this->isContinuation()) ? '' : Util::pack($this->getType() | $this->channel);
			$binary .= Util::pack($this->param1, $this->param2);
			return $binary;
		}
		
		public function getData() {
			return array(
				$this->channel,
				$this->param1,
				$this->param2
			);
		}
		
		public function getLength() {
			return ($this->isContinuation) ? 2 : 3;
		}
		
		public function setContinuation($isContinuation) {
			$this->isContinuation = (bool)$isContinuation;
		}
		
		public function isContinuation() {
			return $this->isContinuation;
		}
		
	}

?>